package github.javaguide;

import java.util.*;

/**
 * @Author: DRevelation
 * @Date: 2020/12/23 9:46
 */
public class ComparatorDemo {
    public static void main(String[] args) {

        List<Integer> list = new ArrayList<>();
        list.add(-1);
        list.add(3);
        list.add(3);
        list.add(-5);
        list.add(7);
        list.add(4);
        list.add(-9);
        list.add(-7);
        System.out.println("原始数组:");
        System.out.println(list);

        Collections.reverse(list);
        System.out.println("Collections.reverse:");
        System.out.println(list);

        Collections.sort(list);
        System.out.println("Collections.sort:");
        System.out.println(list);

        Collections.sort(list, ((o1, o2) -> o2.compareTo(o1)));
        System.out.println("定制排序后:");
        System.out.println(list);
    }
}
